package com.darrenchan.spark.rdd

import org.apache.spark.{SparkConf, SparkContext}

object SparkCoreApp {
  def main(args: Array[String]): Unit = {
    val sparkConf = new SparkConf().setMaster("local[2]").setAppName("SparkCoreApp")
    val sc = new SparkContext(sparkConf)

    //业务逻辑
    val data = List(1, 2, 3, 4, 5)
    val distData = sc.parallelize(data)
    println(distData.collect().mkString(" "))


    val rdd1 = sc.parallelize(List(("cc", 1)))
    val rdd2 = sc.parallelize(List(("cc", 2)))
    val rdd3 = sc.parallelize(List(("cc", 3)))

    println(rdd1.flatMap(_._1).collect().mkString(""))

    println(rdd1.leftOuterJoin(rdd2).leftOuterJoin(rdd3).collect().mkString(""))

    sc.stop()
  }
}
